package com.websocket.controller;

import com.websocket.pojo.Message;
import jakarta.annotation.Resource;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.stereotype.Controller;

@Controller
public class MessageController {
//	@MessageMapping("/sendAll")
//	@SendTo("/topic/receiveAll")
//	Message say(Message message){
//		return message;
//	}
	@Resource
	SimpMessagingTemplate messagingTemplate;
	@MessageMapping("/sendAll")
	void sendAll(Message message){
		messagingTemplate.convertAndSend("/topic/receiveAll",message);
	}
}
